In [1]:
1 + 1


Out[1]:
2

In [2]:
90 * 10


Out[2]:
900

In [3]:
2 ** 2


Out[3]:
4

In [4]:
2 ** (2 ** 3)


Out[4]:
256

In [7]:
1 + (2 * 3)


Out[7]:
7

In [9]:
(9 * 93) + (2339 - 138)


Out[9]:
3038

In [10]:
8 % 4


Out[10]:
0

In [11]:
7 % 3


Out[11]:
1

Modulo weirdness

This 49 happens because of how the modulo operation is defined in mathematics. You can read more about it here: https://en.wikipedia.org/wiki/Modulo_operation AND http://math.stackexchange.com/questions/519845/modulo-of-a-negative-number

For Python specifically you can read about it here: https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations


In [19]:
-1 % 50


Out[19]:
49

In [24]:
-3 // 4


Out[24]:
-1

Modulo Workings

This comes out to 12 becuase you do remainder division. 12 divided by 15 is 0 with a remainder of 12. Or thinking about it in another way. 15 can fit into 12 0 times. There are still 12 pieces left over and that is the remainder.


In [23]:
12 % 15


Out[23]:
12

In [ ]:
8